package com.lx.utils;


import org.apache.commons.text.StringEscapeUtils;

import java.beans.PropertyEditorSupport;

/**
 * Created by lanyxp on 2020/6/23
 * 使用apache-commns作为防xxs web 注入
 */
public class StringConverEditor extends PropertyEditorSupport {
    @Override
    public String getAsText() {
        final Object value = getValue();

        return value != null ? value.toString() : "";
    }
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        setAsText(text == null ? null : StringEscapeUtils.escapeHtml4(text));
    }
}
